function out = knn(COVtest,COVtrain,Ytrain,K)

for i=1:size(COVtest,3)
    d(:,i) = distance_set(COVtrain,COVtest(:,:,i),'riemann');
end

[~,ix] = sort(d,1,'ascend');

a = Ytrain(ix(1:K,:));

for i=1:size(COVtest,3)
    [x,y] = hist(a(:,i),unique(a(:,i)));
    [~,ix] = max(x);
    out(i) = y(ix(1));
end



